//引入组件库
var do_App = sm("do_App");
var do_Page = sm("do_Page");
var nf = sm("do_Notification");
var communityUtil = require("helper/community");
// 声明UI变量
var root = ui("$"); // $表示当前视图的根UI
var aLayoutRoot = ui("aLayoutRoot");
var labelName = ui("labelName");
var labelAddress = ui("labelAddress");
var labelDistance = ui("labelDistance");
var labelIsOpen=ui("labelIsOpen");
// 设置数据绑定的映射关系
root.setMapping({
	"aLayoutRoot.tag" : "id",
	"labelName.text" : "name",
	"labelIsOpen.tag" : "isOpen",
	"labelAddress.text" : "address",
	"labelDistance.text" : "intDistance",
	"selectCheck.tag" : "checked"
});
root.on("dataRefreshed", function() {
	if(labelIsOpen.tag==2){//未开通
		labelIsOpen.text="(未开通)";
		labelName.fontColor="949EAAFF";
	}else{
		labelIsOpen.text="";
		labelName.fontColor="FF7E00FF";
	}
	if(selectCheck.tag){
		selectCheck.source=iconCheck[1];
	}
})
aLayoutRoot.on("touch", function() {
	if(labelIsOpen.tag==2){//未开通
		nf.toast("该社区还未开通服务，敬请留意。");
		return;
	}
	communityUtil.communityVisitId(this.tag);
	do_App.closePage({fromPage:"distance"});
})


var selectCheck = ui("selectCheck");
var iconCheck = ["source://image/common/checkbox.png","source://image/common/checkboxcheck.png"]
ui("checkSelect").on("checkChanged", function(isCheck) {
	var obj = {};
	obj.checked = isCheck;
	isCheck?selectCheck.source=iconCheck[1]:selectCheck.source=iconCheck[0];
	obj.id = aLayoutRoot.tag;
	do_Page.fire("listCheckChange", obj);
})
